<cfcomponent extends="mxunit.framework.TestCase"
            hint="">

  <cffunction name="setUp"  output="true">
    <cfset _i = structNew() />
    <cfset _i.queryloader= createObject("component","org.coldquery.virtualquery.QueryLoader") />
  </cffunction>

  <cffunction name="testInit"  output="true">
    <!--- what does QueryLoader do?
      Takes an initialized Gateway component, the name of a find method and arguments to the find method.
      Arguments can be in the form of a struct, not an array since that's cf's natrual arguments usage.
    --->
    <cfscript>
      //i'm using cfscript for this one just to see how that goes.
      var mockGatewayComponent = createObject("component","DummyGateway");
      var argsstruct= structNew();
      var res = "";
      argsstruct.name="joe"; //there are 6 joes in the test data
      _i.queryloader.init(mockGatewayComponent,"finditems","getSize",argsstruct);

      res = mockGatewayComponent.findItems("joe");
      assertTrue(isArray(res),"gateway.finditems should return an array");
      assertequals(6,arrayLen(res),"gateway should return a 6 item array");

      res = _i.queryloader.size();//size should return 6.  the size of the list
      assertEquals(res,6,"QueryLoader.size() should return 6");

      res = _i.queryloader.load();//load should return an array of structs
      assertTrue(isArray(res),"QueryLoader.load() should return an array");
      assertequals(6,arrayLen(res),"QueryLoader.load() should return a 6 item array");

      //QueryLoader should be efficient if it can and not load all the items first just like for size.
      //This shouldn't be a problem if it's by id, but for any other property I don't know of a way around
      //loading alll of the objects except to add a where clause condition to the sql statement
      //this could get overly complicated and the gateway has to support it.
      res = _i.queryloader.findByProperty("state","NC");//load should return an array of structs
      //debug(res);
      assertTrue(isArray(res),"QueryLoader.load() should return an array");
      assertequals(3,arrayLen(res),"QueryLoader.load() should return a 3 item array - 3 items with name EQ joe and state EQ NC");
      for(i=1;i<arrayLen(res);i++){
      	debug('yes:'&i);
        assertTrue(res[1].state EQ 'NC');
      }

    </cfscript>
  </cffunction>
</cfcomponent>